﻿@model Consumer.Models.ScoredAssignmentModel

<tr>
    <td>
        <span title="@(Model.Description ?? Model.Name)">@Model.Name</span>
    </td>
    <td>
        @if (!string.IsNullOrEmpty(Model.Url))
        {
            @(new Uri(Model.Url).Host)
        }
    </td>
    @if (Model.Course.EnrolledUsers.Any(u => u.Id == Model.UserId))
    {
        <td>
            <div>
                @if (string.IsNullOrEmpty(Model.Score))
                {
                    <text>&nbsp;</text>
                }
                else
                {
                    @Model.Score
                }
            </div>
        </td>
    }
    <td>
        @Html.ActionLink("Launch", "Launch", "Assignment",
        new { id = Model.AssignmentId, returnUrl = @Request == null ? null : Request.Url == null ? null : Request.Url.AbsoluteUri },
            new { @class = "button", target = "_self" })
        @if (User.IsInRole(Consumer.Models.UserRoles.TeacherRole) && Model.Course.Instructor.Id == Model.UserId)
        {
            <text> | </text> @Html.ActionLink("Details", "Details", "Assignment", new { id = Model.AssignmentId }, null)
            <text> | </text> @Html.ActionLink("Edit", "Edit", "Assignment", new { id = Model.AssignmentId }, null)
            <text> | </text> @Html.ActionLink("Delete", "Delete", "Assignment", new { id = Model.AssignmentId }, null)
        }
    </td>
</tr>
